server {
    listen 443 ssl;
    server_name admin-api.fengqingzhai.com;

    root /var/www/html/stall-server/www/adm;
    index index.html index.htm index.php;

    access_log /var/www/logs/admin-api.fengqingzhai.com.log combined;
    error_log /var/www/logs/admin-api.fengqingzhai.com.log error;

    charset utf-8;
    client_max_body_size 100M;
    fastcgi_read_timeout 1800;

    ssl_certificate /etc/nginx/cert/admin-api.fengqingzhai.com/admin-api.fengqingzhai.com.pem;
    ssl_certificate_key /etc/nginx/cert/admin-api.fengqingzhai.com/admin-api.fengqingzhai.com.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    # Represents the root of the domain
    # http://localhost:8000/[index.php]
    location / {
        # Matches URLS `$_GET['_url']`
        try_files $uri $uri/ /index.php?_url=$uri&$args;
    }

    # When the HTTP request does not match the above
    # and the file ends in .php
    location ~ [^/]\.php(/|$) {
        # try_files $uri =404;

        # Ubuntu and PHP7.0-fpm in socket mode
        # This path is dependent on the version of PHP install
        fastcgi_pass  unix:/run/php/php7.3-fpm.sock;

        # Alternatively you use PHP-FPM in TCP mode (Required on Windows)
        # You will need to configure FPM to listen on a standard port
        # https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/
        # fastcgi_pass  127.0.0.1:9000;

        fastcgi_index /index.php;

        include fastcgi_params;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }

        fastcgi_param PATH_INFO       $fastcgi_path_info;
        # fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        # and set php.ini cgi.fix_pathinfo=0


        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        # fastcgi_intercept_errors off;
        # fastcgi_buffer_size 16k;
        # fastcgi_buffers 4 16k;
        # fastcgi_connect_timeout 300;
        # fastcgi_send_timeout 300;
        # fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        add_header Access-Control-Allow-Origin '*';
	add_header Access-Control-Allow-Headers X-Requested-With;
	add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

        expires       max;
        log_not_found off;
        access_log    off;
    }
}

server {
  listen 80;
  server_name admin-api.fengqingzhai.com;
  return 301 https://$server_name$request_uri;
}
